﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


using Baza.EF.BLL;
using Baza.EF.DAL;



namespace Pep_3014_3070_Desktop
{
    public partial class ShowReservation : Form
    {
        public ShowReservation()
        {
            InitializeComponent();
        }

        private void ShowReservation_Load(object sender, EventArgs e)
        {
            cmbIznajmljivac.DataSource = DAIznajmljivaciApartmani.SelectOwners();
            cmbIznajmljivac.DisplayMember = "FirstName,LastName";
        }


        private void cmbIznajmljivac_Format(object sender, ListControlConvertEventArgs e)
        {
            string FirstName = ((Owners)e.ListItem).FirstName;
            string LastName = ((Owners)e.ListItem).LastName;

            e.Value = FirstName + " " + LastName;
        }

       
        private void cmbIznajmljivac_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbApartman.DisplayMember = "";
            cmbApartman.DataSource = DAIznajmljivaciApartmani.SelectApartmentBYOwner((Owners)cmbIznajmljivac.SelectedItem);
            cmbApartman.DisplayMember = "Title";
        }

        private void cmbApartman_SelectedIndexChanged(object sender, EventArgs e)
        {
            Apartments apartment = (Apartments)cmbApartman.SelectedItem;

            dgvRezervacije.DataSource = DAIznajmljivaciApartmani.SelectReservationBYApartment(apartment);

            //dgvRezervacije.RowHeadersVisible = false;

            dgvRezervacije.Columns[0].HeaderText = "Broj rezervacije";
            dgvRezervacije.Columns[1].HeaderText = "Datum dolaska";
            dgvRezervacije.Columns[2].HeaderText = "Datum odlaska";

            dgvRezervacije.Columns[0].Frozen = true;
        }


        




    }
}
